Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 13, 2016
0 parents
commit 30b48bd
Showing
131 changed files
with
4,490 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
20 changes: 20 additions & 0 deletions
20
ProWAS7InternalsSource/Chapter3/BasicOSGI/basicosgi/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
ProWAS7InternalsSource/Chapter3/BasicOSGI/basicosgi/SimpleMaths.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
22 changes: 22 additions & 0 deletions
22
ProWAS7InternalsSource/Chapter3/BasicOSGI/basicosgi/SimpleMathsImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
ProWAS7InternalsSource/Chapter3/TestMyBrowser/org/testwas7/MyBrowser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
150
ProWAS7InternalsSource/Chapter3/WAS7Monitor/was7monitor/Activator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.