Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 13, 2016
0 parents commit 30b48bd
Show file tree
Hide file tree
Showing 131 changed files with 4,490 additions and 0 deletions.
Binary file added 4427.zip
Binary file not shown.
Binary file added 9781430219583.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2009 Colin Renouf

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Binary file added ProWAS7InternalsSource/.DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions ProWAS7InternalsSource/Chapter3/BasicOSGI/basicosgi/Activator.java
@@ -0,0 +1,20 @@
package basicosgi;

import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

public void start(BundleContext context) throws Exception {
// Create the service and its metadata for the registry to use
SimpleMaths service = new SimpleMathsImpl();
Hashtable<String, String> metadata = new Hashtable<String, String>();
metadata.put("Version", "1.0");
context.registerService(SimpleMaths.class.getName(), service, metadata);
}

public void stop(BundleContext context) throws Exception {
}
}
@@ -0,0 +1,11 @@
package basicosgi;

import java.math.BigDecimal;

public interface SimpleMaths {

public BigDecimal add(BigDecimal first, BigDecimal second);
public BigDecimal subtract(BigDecimal first, BigDecimal second);
public BigDecimal multiply(BigDecimal first, BigDecimal second);
public BigDecimal divide(BigDecimal first, BigDecimal second);
}
@@ -0,0 +1,22 @@
package basicosgi;

import java.math.BigDecimal;

public class SimpleMathsImpl implements SimpleMaths {

public BigDecimal add(BigDecimal first, BigDecimal second) {
return (first.add(second));
}

public BigDecimal subtract(BigDecimal first, BigDecimal second) {
return (first.subtract(second));
}

public BigDecimal multiply(BigDecimal first, BigDecimal second) {
return (first.multiply(second));
}

public BigDecimal divide(BigDecimal first, BigDecimal second) {
return (first.divide(second));
}
}
@@ -0,0 +1,57 @@
package org.testwas7;

import org.eclipse.swt.*;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.TitleEvent;
import org.eclipse.swt.browser.TitleListener;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.core.runtime.IPlatformRunnable;

/*
* Simple Browser
*/

// IPlatformRunnable makes this an Eclipse application
public class MyBrowser implements IPlatformRunnable {

// The IPlatformRunnable interface that makes this an eclipse application
// has only a run method that takes an Object as its parameter list
public Object run(Object args) throws Exception {

// Create a sizable application Window for the platform
// that we are going to fill with a single control
Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());

// Create a browser control that shows the title
// of the page we are looking at in the tite bar
Browser browser = new Browser(shell, SWT.NONE);
browser.addTitleListener(new TitleListener() {
public void changed(TitleEvent event) {
shell.setText(event.title);
}
});

// Open the browser window inside the shell window
browser.setBounds(0, 0, 640, 480);
shell.pack();
shell.open();

browser.setUrl("http://www.eclipse.org");

// Process events while we have them and while they are not telling
// use to close the window and exit
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}

// We have finished so exit happily
return EXIT_OK;
}
}


150 changes: 150 additions & 0 deletions ProWAS7InternalsSource/Chapter3/WAS7Monitor/was7monitor/Activator.java
@@ -0,0 +1,150 @@
package was7monitor;

import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IRegistryChangeEvent;
import org.eclipse.core.runtime.IRegistryChangeListener;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;

/**
* The activator class controls the plug-in life cycle
*/
public class Activator
extends Plugin
implements IRegistryChangeListener, IJobChangeListener, BundleListener, ServiceListener {

// The plug-in ID
public static final String PLUGIN_ID = "WAS7Monitor";

// The shared instance
private static Activator plugin;
private static BundleContext bundleContext;

/**
* The constructor
*/
public Activator() {
plugin = this;
}

/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(final BundleContext context) throws Exception {
super.start(context);
bundleContext = context;
System.out.println("WAS7Monitor:Bundle Activator start method called");

// Add a JobManager listener
IJobManager manager = Platform.getJobManager();
manager.addJobChangeListener(this);

// Now output the OSGI artefact inforamtion
// Add a bundle listener
context.addBundleListener(this);

// Add a service listener
context.addServiceListener(this);

// Output the Eclipse runtime artefact information
Utility.output(context, this);

// Add a registry change listener
// For pure Eclipse and not OSGI use Platform.getExtensionRegistry.
// For the OSGI way of doing things, use a ServiceTracker.
// With compatibility both should work.
IExtensionRegistry reg = Platform.getExtensionRegistry();
if (reg != null) {
reg.addRegistryChangeListener(this);
}
}

/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
System.out.println("WAS7Monitor:Bundle Activator stop method called");

// Remove our extension registry listener
IExtensionRegistry reg = Platform.getExtensionRegistry();
if (reg != null) {
reg.removeRegistryChangeListener(this);
}
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}

/**
* Call our utility method to output the registry change
*
* @param event
*/
public void registryChanged(IRegistryChangeEvent event) {
Utility.outputRegistryChange(event);
}

/**
* Call our utility method to output the job changes
*
*/
public void aboutToRun(IJobChangeEvent event) {
Utility.outputJobChange(event, " about to run");
}

public void awake(IJobChangeEvent event) {
Utility.outputJobChange(event, " awake");
}

public void done(IJobChangeEvent event) {
Utility.outputJobChange(event, " done");
}

public void running(IJobChangeEvent event) {
Utility.outputJobChange(event, " running");
}

public void scheduled(IJobChangeEvent event) {
Utility.outputJobChange(event, " scheduled");
}

public void sleeping(IJobChangeEvent event) {
Utility.outputJobChange(event, " sleeping");
}

/**
* Call our utility method to output the bundle changes
*
* @param event
*/
public void bundleChanged(BundleEvent event) {
Utility.outputBundleChange(event);
}

/**
* Call our utility method to output the service changes
*
* @param event
*/
public void serviceChanged(ServiceEvent event) {
Utility.outputServiceChange(bundleContext, event);
}
}

0 comments on commit 30b48bd

Please sign in to comment.